package alarm;

import org.snmp4j.smi.Integer32;

public enum EventType {
	 none("Nessuno"),
	 log("Log"),
	 snmpTrap("Trap SNMP"),    
	 logAndTrap("Log e Trap SNMP");
	
	private String description = null;
	
	private EventType(String description) {
		this.description = description;
	}

	public int getValue() {
		switch (this) {
		case none: default:
			return 1;
		case log:
			return 2;
		case snmpTrap:
			return 3;
		case logAndTrap:
			return 4;
		}
	}

	@Override
	public String toString() {
		return description;
	}

	public static EventType fromString(final String value) {
		if (value.equals(none.toString()))
			return none;
		else if (value.equals(log.toString()))
			return log;
		else if (value.equals(snmpTrap.toString()))
			return snmpTrap;
		else if (value.equals(logAndTrap.toString()))
			return logAndTrap;
		else
			return none;
	}

	public Integer32 toVariable() {
		return new Integer32(getValue());
	}

	public static EventType fromVariable(Integer32 variable) {
		switch (variable.getValue()) {
		case 1: default:
			return none;
		case 2:
			return log;
		case 3:
			return snmpTrap;
		case 4:
			return logAndTrap;
		}
	}
}